<template>
  <transition name="a-loading-fade" @after-leave="handleAfterLeave">
    <div
      v-show="visible"
      class="a-loading-mask"
      :style="{backgroundColor:background||''}"
      :class="[customClass,{'is-fullscreen':fullscreen}]"
    >
      <div :class="[spinner,{'a-loading-spinner':!spinner}]">
        <a-spin :indicator="indicator" :tip="text"></a-spin>
      </div>
    </div>
  </transition>
</template>

<script>
export default {
  data() {
    return {
      text: null,
      spinner: null,
      background: null,
      fullscreen: true,
      visible: true,
      customClass: "",
      indicator: null
    };
  },
  methods: {
    handleAfterLeave() {
      this.$emit("after-leave");
    },
    setText(text) {
      this.text = text;
    },
    setIndicator(indicator) {
      this.indicator = indicator;
    }
  }
};
</script>

